const { DataTypes } = require('sequelize');
const { sequelize } = require('../init'); // 导入数据库连接配置

// 部门
const Department = sequelize.define('Department', {
    DepartmentID: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        allowNull: true,
    },
    DepartmentName: {
        type: DataTypes.STRING(50),
        allowNull: true,
        collate: 'utf8mb4_bin', // 设置字符集规则
    },
    DepartmentDescription: {
        type: DataTypes.TEXT,
        allowNull: true,
        collate: 'utf8mb4_bin', // 设置字符集规则
    },
    Manage: {
        type: DataTypes.STRING(255),
        allowNull: true,
        collate: 'utf8mb4_bin', // 设置字符集规则
    },
    Contact: {
        type: DataTypes.INTEGER,
        allowNull: true,
        collate: 'utf8mb4_bin', // 设置字符集规则
    }
}, {
    tableName: 'department', // 设置表名为 "department"
    timestamps: false, // 如果表中不包含 createdAt 和 updatedAt 字段，请将此选项设置为 false
    collate: 'utf8mb4_bin', // 设置字符集规则
});
// 帮我打印一下数据库连接情况
Department.sync({ force: false }).then(() =>
{
    console.log('部门表准备');
});
module.exports = { Department };
